﻿<?xml version="1.0" encoding="utf-8"?>
<UserControl
	x:Class="Debugger.AddIn.Tooltips.DebuggerTooltipControl"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
	xmlns:debugging="clr-namespace:Debugger.AddIn.Tooltips" xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:localControls="clr-namespace:Debugger.AddIn.Tooltips"
	Background="Transparent">
	<UserControl.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary
					Source="VisualizerPicker.xaml" />
				<ResourceDictionary
					Source="PinControlsDictionary.xaml" />
			</ResourceDictionary.MergedDictionaries>
		</ResourceDictionary>
	</UserControl.Resources>
	<StackPanel
		Orientation="Vertical">
		<RepeatButton
			Name="btnUp"
			Focusable="False"
			Style="{StaticResource upButtonStyle}"
			Content="^"
			Click="BtnUp_Click"></RepeatButton>
		<DataGrid
			VerticalScrollBarVisibility="Disabled"
			HorizontalScrollBarVisibility="Disabled"
			GridLinesVisibility="None"
			RowHeight="18"
			MaxHeight="202"
			SelectionMode="Single"
			SelectionUnit="FullRow"
			ItemsSource="{Binding}"
			Name="dataGrid"
			AutoGenerateColumns="False"
			CanUserAddRows="False"
			HeadersVisibility="None"
			BorderBrush="Gray"
			BorderThickness="1">
			<DataGrid.Background>
				<!-- Control backgound -->
				<LinearGradientBrush
					StartPoint="0,-0.03"
					EndPoint="0,1">
					<GradientStop
						Color="White" />
					<GradientStop
						Color="#FFFAFCFE"
						Offset="0.983" />
					<GradientStop
						Color="#FFECF7FC"
						Offset="0.07" />
					<GradientStop
						Color="#FFEEF7FA"
						Offset="0.436" />
				</LinearGradientBrush>
			</DataGrid.Background>
			<DataGrid.RowStyle>
				<Style
					TargetType="{x:Type DataGridRow}">
					<Setter
						Property="Background"
						Value="Transparent"></Setter>
					<Style.Triggers>
						<Trigger
							Property="IsMouseOver"
							Value="True">
							<Setter
								Property="Background"
								Value="#FFE2F6FE" />
						</Trigger>
					</Style.Triggers>
				</Style>
			</DataGrid.RowStyle>
			<DataGrid.CellStyle>
				<Style
					TargetType="{x:Type DataGridCell}">
					<Setter
						Property="Focusable"
						Value="false" />
					<!-- Focusable=true blocks shortcuts if cell is focused -->
					<Setter
						Property="BorderThickness"
						Value="0" />
					<Style.Triggers>
						<Trigger
							Property="IsSelected"
							Value="True">
							<!-- disable selection highlight -->
							<Setter
								Property="Foreground"
								Value="Black" />
							<Setter
								Property="Background"
								Value="{x:Null}" />
						</Trigger>
					</Style.Triggers>
				</Style>
			</DataGrid.CellStyle>
			<DataGrid.Columns>
				<DataGridTemplateColumn>
					<!-- "Plus" expander -->
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Grid
								Background="White">
								<StackPanel
									VerticalAlignment="Center">
									<ToggleButton
										x:Name="btnExpander"
										Style="{StaticResource ExpandCollapseToggleStyle}"
										Click="btnExpander_Click"
										Padding="0"
										Margin="0" />
								</StackPanel>
							</Grid>
							<DataTemplate.Triggers>
								<DataTrigger
									Binding="{Binding Path=HasChildNodes}"
									Value="False">
									<Setter
										TargetName="btnExpander"
										Property="Visibility"
										Value="Collapsed" />
								</DataTrigger>
							</DataTemplate.Triggers>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<!-- Icon -->
				<DataGridTemplateColumn>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Image
								Source="{Binding ImageSource}"></Image>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTemplateColumn
					MinWidth="20"
					Header="Name">
					<!-- Name -->
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<Border
								BorderBrush="#FFDDDDDD"
								BorderThickness="0 0 1 0">
								<TextBlock
									Style="{StaticResource TextBlockStyle}"
									Text="{Binding Path=Name, Mode=OneWay}"
									VerticalAlignment="Top"></TextBlock>
							</Border>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<!-- Visualizer picker  -->
				<DataGridTemplateColumn>
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<debugging:VisualizerPicker
								Focusable="False"
								x:Name="visPicker"
								ItemsSource="{Binding Path=VisualizerCommands, Mode=OneWay}"
								Margin="4 0 0 0"></debugging:VisualizerPicker>
							<DataTemplate.Triggers>
								<DataTrigger
									Binding="{Binding Path=HasVisualizerCommands}"
									Value="False">
									<Setter
										TargetName="visPicker"
										Property="Visibility"
										Value="Collapsed" />
								</DataTrigger>
							</DataTemplate.Triggers>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTemplateColumn
					MinWidth="20"
					Header="Text">
					<!-- Text (value) -->
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<TextBox
								Style="{StaticResource TextStyle}"
								IsEnabled="{Binding CanSetText}"
								KeyUp="TextBox_KeyUp"
								ContextMenuService.ShowOnDisabled="True"
								Text="{Binding Path=Text}">
								<TextBox.ContextMenu>
									<ContextMenu>
										<MenuItem Header="{core:Localize XML.MainMenu.EditMenu.Copy}" DataContext="{Binding}" Click="CopyMenuItemClick">
											<MenuItem.Icon>
												<Image Source="{core:GetBitmap Icons.16x16.CopyIcon}" />
											</MenuItem.Icon>
										</MenuItem>
									</ContextMenu>
								</TextBox.ContextMenu>
							</TextBox>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
				<DataGridTemplateColumn>
					<!-- Pin -->
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<ToggleButton
								IsChecked="{Binding IsPinned}"
								DataContext="{Binding}"
								Visibility="Collapsed"
								Name="PinButton"
								VerticalAlignment="Center"
								Checked="PinButton_Checked"
								Unchecked="PinButton_Unchecked"
								Template="{StaticResource PinTooltipButtonTemplate}" />
							<DataTemplate.Triggers>
								<DataTrigger
									Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGridRow}}"
									Value="True">
									<Setter
										TargetName="PinButton"
										Property="Visibility"
										Value="Visible" />
								</DataTrigger>
							</DataTemplate.Triggers>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
			</DataGrid.Columns>
		</DataGrid>
		<RepeatButton
			Name="btnDown"
			Focusable="False"
			Style="{StaticResource downButtonStyle}"
			Content="v"
			Click="BtnDown_Click"></RepeatButton>
	</StackPanel>
</UserControl>